<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <% String contextPath = request.getContextPath(); 
    request.setAttribute("contextPath", contextPath);%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
  	<meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
                

    <title>消息设置</title>

    <!-- Bootstrap Core CSS -->
    <link href="${contextPath}/css/bootstrap.min.css" rel="stylesheet">

    <!-- MetisMenu CSS -->
    <link href="${contextPath}/css/metisMenu.min.css" rel="stylesheet">

    <!-- Custom CSS -->
    <link href="${contextPath}/css/sb-admin-2.css" rel="stylesheet">

    <!-- Custom Fonts -->
    <link href="${contextPath}/css/font-awesome.min.css" rel="stylesheet" type="text/css">

    <!--common Css-->
    <link href="${contextPath}/css/common.css" rel="stylesheet">

    <!--robot Css-->
    <link href="${contextPath}/css/robot.css" rel="stylesheet">

    <link rel="stylesheet" href="${contextPath}/css/bootstrap-switch.min.css">
    <link href="${contextPath}/iconfont/iconfont.css" rel="stylesheet">
</head>

<body>

    <div id="wrapper">

        <!-- Navigation -->
         <%@include file="nav.jsp"%>

        <div id="page-wrapper">
            <form role="form" class="form-horizontal" method="post" enctype="multipart/form-data" action="">
                <div class="row">
                    <div class="col-lg-12">
                        <h3 class="page-header">消息设置</h3>
                    </div>
                    <!-- /.col-lg-12 -->
                </div>
                <!-- /.row -->
                <div class="row">
                    <div class="col-lg-6">
                        <div class="form-group">
                            <label for="welcome" class="col-sm-3 control-label">机器人欢迎语</label>
                            <div class="col-xs-12">
                                <input type="text" class="form-control"  id="welcome" name="welcome" value="${Type0.data.question }">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="rote" class="col-sm-3 control-label">未知问题回答</label>
                            <div class="col-xs-12">
                                <input type="text" class="form-control"  id="rote" name="rote" value="${Type2.data.question }">
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row ">
                        <div class="form-group ">
                            <div class="col-md-6 col-md-offset-3 ">
                                <button type="button" class="btn btn-default " id="save" >保存</button>
                                <button type="reset" class="btn btn-default ">取消</button>
                            </div>
                        </div>
                    </div>
                </div>
            </form>
        </div>
        <!-- /#page-wrapper -->

    </div>
    <!-- /#wrapper -->

 

    <!-- jQuery -->
    <script src="${contextPath}/js/jquery.min.js "></script>

    <!-- Bootstrap Core JavaScript -->
    <script src="${contextPath}/js/bootstrap.min.js "></script>

    <!-- Metis Menu Plugin JavaScript -->
    <script src="${contextPath}/js/metisMenu.min.js "></script>

    <!-- Custom Theme JavaScript -->
    <script src="${contextPath}/js/sb-admin-2.min.js "></script>

    <script src="${contextPath}/js/bootstrap-switch.min.js"></script>

    <!-- Page-Level Demo Scripts - Tables - Use for reference -->
    
    <script type="text/javascript" charset="UTF-8">
    
        $(function() {
            $("[name='my-checkbox']").bootstrapSwitch({
                onText: "开启",
                offText: "关闭",
                onSwitchChange:function(event, state){
                    if(state == true){
                        $(this).val("1");
                    }else{
                        $(this).val("2");
                    }
                }
            });

            $('[data-toggle="popover "]').popover();

            $("#addQuestion ").click(function() {
                $("#questionModal ").modal('show');
            });

            //提示信息封装函数
            function notice(notice) {
                var str = '';
                str += '<div class="popupTip ">';
                str += notice;
                str += '<span class="glyphicon glyphicon-remove "></span>';
                str += '</div>';
                str += '</strong></div>';
                //wrapper插入str
                $("#wrapper ").append(str);
            }

            //取消提示框
            $("#wrapper ").on('click', '.glyphicon-remove', function() {
                $(".popupTip ").hide();
            });
            
        });
        
        
        
        //保存事件
        $(function(){
        	$("#save").click(function(){
        		var welcome = $("#welcome").val();
        		
        		var rote = $("#rote").val();
        		
        		
        		 $.ajax({
                     type: 'POST',
                     url:'${contextPath}/WebManager/manage/welcome',
                     data: {
                    	 welcome:welcome,
     					rote:rote,
                     },
                     dataType: 'json',
                     success: function(data) {
                    	 if(data.status != 1){
                    		 console.log(data);   
                    		 alert('添加成功 ');
          				}else{
          					notice("添加失败!");
          				}                                             
                     },
                 });
        	});
        })
             
        
    </script>

</body>

</html>